package io.finer.erp.jeecg.bas.service;

import io.finer.erp.jeecg.bas.entity.BasCategoryLabel;
import io.finer.erp.jeecg.bas.entity.BasMaterialCategory;
import com.baomidou.mybatisplus.extension.service.IService;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: 物料分类
 * @Author: jeecg-boot
 * @Date:   2020-05-29
 * @Version: V1.0
 */
public interface IBasMaterialCategoryService extends IService<BasMaterialCategory> {

	/**根节点父ID的值*/
	public static final String ROOT_PID_VALUE = "0";
	
	/**树节点有子节点状态值*/
	public static final String HASCHILD = "1";
	
	/**树节点无子节点状态值*/
	public static final String NOCHILD = "0";

	/**新增节点*/
	void addBasMaterialCategory(BasMaterialCategory basMaterialCategory);
	
	/**修改节点*/
	void updateBasMaterialCategory(BasMaterialCategory basMaterialCategory) throws JeecgBootException;
	
	/**删除节点*/
	void deleteBasMaterialCategory(String id) throws JeecgBootException;
	
	/**
	 * @Description 获取该节点的根节点，用来判断是产品、半成品还是物料
	 * @param id
	 * @return
	 * Create at: 2020-09-24 13:39:17
	 * @author: duanyong
	 * Revision:
	 *    2020-09-24 13:39:17 - first revision by duanyong
	 *        
	 */
	public BasMaterialCategory getRootCategory(String id);
	
	/**
	 * @Description 获取分类节点的子节点
	 * @param rootId
	 * @return
	 * Create at: 2020-09-24 15:16:59
	 * @author: duanyong
	 * Revision:
	 *    2020-09-24 15:16:59 - first revision by duanyong
	 *        
	 */
	public List<BasMaterialCategory> getChildCategory(String rootId);

	/**
	 * @Description 获取半成品分类下的子分类 (hasChild = 0 或null)
	 * @return
	 * Create at: 2020-10-08 11:48:01
	 * @author: duanyong
	 * Revision:
	 *    2020-10-08 11:48:01 - first revision by duanyong
	 *        
	 */
	Result<?> getBCPCategory();

	/**
	 * @Description 获取产品分类下的子分类 (hasChild = 0 或null)
	 * @return
	 * Create at: 2020-10-08 11:49:20
	 * @author: duanyong
	 * Revision:
	 *    2020-10-08 11:49:20 - first revision by duanyong
	 *        
	 */
	Result<?> getCPCategory();
	
	
	/**
	 * @Description 查询原材料下的所有物料分类
	 * @param childFlag 是否只查询没有下级的子节点
	 * @return
	 * Create at: 2020-10-10 09:10:08
	 * @author: duanyong
	 * Revision:
	 *    2020-10-10 09:10:08 - first revision by duanyong
	 *        
	 */
	Result<?> getMaterialCategory(boolean childFlag);
	
	/**
	 * @Description 根据分类ID
	 * @param id
	 * @return
	 * Create at: 2020-10-20 18:37:11
	 * @author: duany
	 * Revision:
	 *    2020-10-20 18:37:11 - first revision by duany
	 *        
	 */
	String getCategoryRoot(String id);
	
	/**
	 * @Description 吨转平方计算方法
	 * @param qty
	 * @param categoryId
	 * @return
	 * Create at: 2020-10-13 17:17:45
	 * @author: duanyong
	 * Revision:
	 *    2020-10-13 17:17:45 - first revision by duanyong
	 *        
	 */
	public BigDecimal getSquare(BigDecimal qty, String categoryId);

	/**
	 * @Description 根据平方转吨
	 * @param square 平方
	 * @param categoryId 物料分类ID
	 * @return
	 * Create at: 2020-10-22 10:47:19
	 * @author: duany
	 * Revision:
	 *    2020-10-22 10:47:19 - first revision by duany
	 *        
	 */
	BigDecimal getTon(BigDecimal square, String categoryId);
	
	/**
	 * @Description 根据传入的ID获取该分类对应的自有产品的分类，如果没有，则在自有产品下新建一个。
	 * @param id
	 * @return
	 * Create at: 2020-11-23 10:53:14
	 * @author: duany
	 * Revision:
	 *    2020-11-23 10:53:14 - first revision by duany
	 *        
	 */
	public BasMaterialCategory getCPCategory(String id);

	Result<?> getCengPinCategory();

	Result<?> getCategory();

	Result<?> getOrderCategory(String orderId);

	/**
	 * @Description 获得胶水的物料分类
	 * @return
	 * Create at: 2021-03-06 09:38:01
	 * @author: duany
	 * Revision:
	 *    2021-03-06 09:38:01 - first revision by duany
	 *        
	 */
	Result<?> getGlueCategory();
	
	/**
	 * 获取物料分类
	 * @return
	 */
	Result<?> getCategoryName();

	/**
	 * @Description 查询物料分类的标签
	 * @param categoryId
	 * @return
	 * Create at: 2021-08-11 11:18:54
	 * @author: duany
	 * Revision:
	 *    2021-08-11 11:18:54 - first revision by duany
	 *        
	 */
	Result<List<BasCategoryLabel>> getCategoryLabel(String categoryId);

}
